@extends('layout.default')

@section('stylesheet')
<link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/bootstrap-markdown/2.10.0/css/bootstrap-markdown.min.css" rel="stylesheet">
@stop

@section('content')

  @include('layout.breadcrums')
	{{ csrf_field() }}
	<div class="weui-cells weui-cell_access">
		<article class="weui-article">
      <textarea class="weui-textarea" id="intro" name="intro" rows="18">{{$text->content}}</textarea>
    </article>
    <div class="weui-form__tips-area">
      <p class="weui-form__tips">
        <b>编辑器仅支持Markdown语法</b>
      </p>
    </div>	   
    <div class="weui-btn-area weui-form__opr-area">
      <button class="weui-btn weui-btn_primary submit">确定</button>
    </div>
  </div>

	
@stop

@section('javascript')
    <script src="//cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap-markdown/2.10.0/js/bootstrap-markdown.min.js"></script>
    <script src="/assets/js/bootstrap-markdown.zh.js" type="text/javascript"></script>
    <script type="text/javascript">
      $(function() {

        $('.submit').on('click', function() {            
          var uri = '{{route('super.postText')}}';
          var id = '{{$text->id}}';
          $.post(uri, {
            '_token':$("input[name='_token']").attr('value'),
            'id': id,
            'intro': $("#intro").val(),
            'is_submit': true
          }, function(data) {
            layer.msg(data.message, { shift: -1 },function(){
              if(data.status === true && data.url != null ){
                $(window).attr('location', data.url);
              } 
            }); 

          },'json').error(function(data){
            layer.msg(data.responseJSON.message);
          }); 
          
        });


        $("#intro").markdown({
          autofocus: true,
          language: 'zh',
          hiddenButtons: ['cmdCode','cmdQuote'],
        })

      });
    </script>

@stop